/******************* 公共变量 *******************/
var urlData = core.getUrlData(['tui_id', 'a_id']);

/******************* Vue初始化代码 *******************/
var vm = new Vue({
	el: '.wrap',
	data: {
		wrapHeight: winHeight,
		phone: '',
		password: '',
		btnJudge: true,
		tui_id: urlData[0],
		a_id: urlData[1],
		forgetUrl: forgetUrl,
		wxLogin: (urlData[0] ? (wxLoginUrl + '?tui_id=' + urlData[0] + '&a_id=' + urlData[1]) : wxLoginUrl),
		loginFun: function () {
			var _this = this;
			if (core.phoneJudge(this.phone)) {
				if (core.pwJudge(this.password)) {
					if (this.btnJudge) {
						this.btnJudge = false;
						$.ajax({
							url: loginUrl,
							type: 'post',
							data: {
								mobile: _this.phone,
								password: _this.password,
								tui_id: (urlData[0] ? urlData[0] : ''),
								a_id: (urlData[1] ? urlData[1] : '')
							},
							success: function(data) {
								console.log(data)

								setTimeout(function () {
									_this.btnJudge = true;
								}, 1000);
								if (data.result == 1) {
									core.hintHref(data.message, indexUrl);
								} else {
									core.layerHint(data.message);
								}
							}
						});
					}
				} else {
					core.layerHint('请输入6-16位，字母或数字密码');
				}
			} else {
				core.layerHint('请输入正确手机号');
			}
		}
	},
	methods: {
		phoneJudge: function () {
			!core.phoneJudge(this.phone) && core.layerHint('请输入正确手机号');
		},
		passwordJudge: function () {
			!core.pwJudge(this.password) && core.layerHint('请输入6-16位，字母或数字密码');
		},
		login: function () {
			this.loginFun();
		},
		keyLogin: function (event) {
			(event.keyCode == 13) && this.loginFun();
		}
	},
	computed: {
		
	},
	components: {
		
	},
	created: function () {
		
	},
	mounted: function () {
		common.bindBack();
	}
});

